import axios from 'axios';
import { urls } from './url.js';
import { getBaseUrl } from '../utils/env.js';

const uploadMod = (formData, id) => {
  let headers = {
    'Content-Type': 'multipart/form-data',
    id
  };
  return new Promise((resolve, reject) => {
    axios
      .post(getBaseUrl() + 'kd/uploadMod', formData, {
        headers,
      })
      .then((res) => {
        if (res.data.code !== 200) {
          console.log('upload err', res.data || res);
          reject(res.data || res);
        }
        resolve(res.data.data);
      })
      .catch((err) => {
        console.log('upload err', err.data || err);
        reject(err.data || err);
      });
  });
};

export { uploadMod }
